﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Configuration;

namespace LibraryReservation
{
    public sealed class CreateResponse:CodeActivity
    {
        public InArgument<ReservationRequest> Request { get; set; }
        public InArgument<bool> Reserved { get; set; }
        public OutArgument<ReservationResponse> Response { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            ReservationResponse r = new ReservationResponse(
                Request.Get(context),
                Reserved.Get(context),
                new Branch
                {
                    BranchName = ConfigurationManager.AppSettings["Branch Name"],
                    BranchID = new Guid(ConfigurationManager.AppSettings["ID"]),
                    Address = ConfigurationManager.AppSettings["Address"]
                }
            );
            Response.Set(context, r);
        }
    }
}
